package com.lsy.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lsy.entity.AccountAndArticleCnd;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 项目名：springboot01
 * 包名：com.lsy.dao
 * 类名：AccountAndArticleCndMapper
 * 描述：
 * 作者：柳胜酉
 * 开始时间：2023/6/13
 * 完成时间：
 * 版本：1.0
 */
@Mapper
public interface AccountAndArticleCndMapper extends BaseMapper<AccountAndArticleCnd> {
    @Select("select article.article_id,article.article_title," +
            "article.article_content,article.type_name,article.upload_time," +
            "article.article_likes,article.state,account.user_id,account.account," +
            "account`password`,account.role from article,account " +
            "where article.user_id = account.user_id and article.state = 1 and article.user_id = #{user_id} order by article.upload_time desc")
    List<AccountAndArticleCnd> selectAccountAndArticleCndByUserId(Integer user_id);

    @Select("select article.article_id,article.article_title," +
            "article.article_content,article.type_name,article.upload_time," +
            "article.article_likes,article.state,account.user_id,account.account," +
            "account`password`,account.role from article,account " +
            "where article.user_id = account.user_id and article.state = 1 order by article.upload_time desc;")
    List<AccountAndArticleCnd> selectAccountAndArticleCnd();

    @Select("select article.article_id,article.article_title," +
            "article.article_content,article.type_name,article.upload_time," +
            "article.article_likes,article.state,account.user_id,account.account," +
            "account`password`,account.role from article,account " +
            "where article.user_id = account.user_id and article.state = 0 order by article.upload_time desc;")
    List<AccountAndArticleCnd> selectAccountAndArticleCndReview();

    @Select("select article.article_id,article.article_title," +
            "article.article_content,article.type_name,article.upload_time," +
            "article.article_likes,article.state,account.user_id,account.account," +
            "account`password`,account.role from article,account " +
            "where article.user_id = account.user_id and article.state = 2 order by article.upload_time desc;")
    List<AccountAndArticleCnd> selectAccountAndArticleCndFailed();
}
